//
//  DKContactController.m
//  DanKU
//
//  Created by 蓝鳍互娱 on 2023/11/27.
//

#import "DKContactController.h"

@interface DKContactController ()<CNContactPickerDelegate>

@end

@implementation DKContactController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.delegate = self;
    //获取拓展信息
    [[DKAuthExtHelper defaultManager] checkExtExpired];
}
#pragma mark -- CNContactPickerDelegate
-(void)contactPicker:(CNContactPickerViewController *)picker didSelectContactProperty:(CNContactProperty *)contactProperty{
    WeakSelf(self)
    if(![contactProperty.key isEqualToString:@"phoneNumbers"]){
        return;
    }
   
    CNPhoneNumber * phoneNumber = (CNPhoneNumber*)contactProperty.value;

    NSString *name = [NSString stringWithFormat:@"%@%@",contactProperty.contact.familyName,contactProperty.contact.givenName];
    [self dismissViewControllerAnimated:YES completion:^{
        /// 联系人
//        /// 电话
//        CNLabeledValue  *phoneLabeledValue = [contactProperty.contact.phoneNumbers firstObject];
//        CNPhoneNumber *phoneValue = phoneLabeledValue.value;
        if(weakSelf.SelectContactScuessBlock){
            NSString *phone = phoneNumber.stringValue;
            weakSelf.SelectContactScuessBlock(phone, name);
        }
    }];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
